<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>test</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }

        body {
            user-select: none;
        }

        .box{
            position: relative;
            width: 613px;
            height: 230px;
            margin: 50px auto;
            /* overflow: hidden; */
        }

        ul.list {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        li {
            width: 100%;
            height: 100%;
        }

        li img{
            width: 100%;
        }

        .arrow {
            position: absolute;
            top: 50%;
            right: 30px;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background-color: rgba(0,0,0,.5);
            cursor: pointer;
        }

        .arrow::after {
            content: "";
            position: absolute;
            top: 10px;
            left: 8px;
            width: 7px;
            height: 7px;
            border: 3px solid #fff;
            border-width: 3px 3px 0 0;
            transform: rotate(45deg);
        }

        .arrow-l {
            left: 30px;
        }

        .arrow-l::after {
            left: 12px;
            border-width: 3px 0 0 3px;
            transform: rotate(-45deg);
        }

        .dots {
            position: absolute;
            top: 50%;
            right: -14px;
            width: 14px;
            transform: translateY(-50%);
        }

        .dots li {
            width: 10px;
            height: 10px;
            margin: 10px 2px;
            border-radius: 50%;
            background-color: #f00;
        }
    </style>
</head>
<body>
    <div class="box">
        <ul class="list">
            <li><img src="../lib/image/bom/m1.jpg" alt=""></li>
            <li><img src="../lib/image/bom/m2.jpg" alt=""></li>
            <li><img src="../lib/image/bom/m3.jpg" alt=""></li>
            <li><img src="../lib/image/bom/m4.jpg" alt=""></li>
            <li><img src="../lib/image/bom/m1.jpg" alt=""></li>
        </ul>

        <div class="arrow arrow-l"></div>
        <div class="arrow arrow-r"></div>

        <ul class="dots">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
    

    <script type="text/javascript">
        var arrows = document.querySelectorAll(".arrow"),
            list = document.querySelector(".list"),
            length = list.children.length;
            count = 0,
            h = list.offsetHeight;

        arrows[0].onclick = function (){
            if(count == 0){
                count = length - 1;
                list.style.top = -count * h + "px";
            }
            count --;
            move(list);
        }

        arrows[1].onclick = function (){
            if(count == length - 1){
                count = 0;
                list.style.top = "0px";
            }
            count ++;
            move(list);
        }


        function move(ele){
            var end = -count * h;
            if(ele.timer){
                clearInterval(ele.timer);
            }
            ele.timer = setInterval(function (){
                var start = ele.offsetTop;
                var step = (end - start)/10;
                if(Math.abs(step) < 1){
                    step = step > 0 ? 1 : Math.floor(step);
                }

                ele.style.top = start + step + "px";

                if(start + step === end){
                    clearInterval(ele.timer);
                    ele.timer = null;
                }
            }, 1000/60);
        }
    </script>
</body>
</html>